package com.ruoyi.web.controller.fan;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.Mainventilator1History;
import com.ruoyi.control.service.IMainventilator1HistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主通风机1号风机历史数据Controller
 *
 * @author ruoyi
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/control/mainvenHistory")
public class  Mainventilator1HistoryController extends BaseController
{
    @Autowired
    private IMainventilator1HistoryService mainventilator1HistoryService;

    /**
     * 查询主通风机1号风机历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mainventilator1History mainventilator1History)
    {
        startPage();
        List<Mainventilator1History> list = mainventilator1HistoryService.selectMainventilator1HistoryList(mainventilator1History);
        return getDataTable(list);
    }

    /**
     * 导出主通风机1号风机历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:export')")
    @Log(title = "主通风机1号风机历史数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mainventilator1History mainventilator1History)
    {
        List<Mainventilator1History> list = mainventilator1HistoryService.selectMainventilator1HistoryList(mainventilator1History);
        ExcelUtil<Mainventilator1History> util = new ExcelUtil<Mainventilator1History>(Mainventilator1History.class);
        util.exportExcel(response, list, "主通风机1号风机历史数据数据");
    }

    /**
     * 获取主通风机1号风机历史数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:query')")
    @GetMapping(value = "/ByTagName/{tagName}")
    public AjaxResult ByTagName(@PathVariable("tagName") String tagName)
    {
        Integer[] arr=mainventilator1HistoryService.selectMainventilator1HistoryByTagName(tagName);
        return success(arr);
    }

    /**
     * 新增主通风机1号风机历史数据
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:add')")
    @Log(title = "主通风机1号风机历史数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mainventilator1History mainventilator1History)
    {
        return toAjax(mainventilator1HistoryService.insertMainventilator1History(mainventilator1History));
    }

    /**
     * 修改主通风机1号风机历史数据
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:edit')")
    @Log(title = "主通风机1号风机历史数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mainventilator1History mainventilator1History)
    {
        return toAjax(mainventilator1HistoryService.updateMainventilator1History(mainventilator1History));
    }

    /**
     * 删除主通风机1号风机历史数据
     */
    @PreAuthorize("@ss.hasPermi('control:mainvenHistory:remove')")
    @Log(title = "主通风机1号风机历史数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mainventilator1HistoryService.deleteMainventilator1HistoryByIds(ids));
    }

    /**
     * 主通风机1故障次数  3天、1天
     */
    @GetMapping("/getMainOneTotal")
    public int getMainOneTotal()
    {
        int total = mainventilator1HistoryService.getMainOneTotal();
        return total;
    }

}
